package com.liuzy.crawler.core;

import com.liuzy.crawler.Config;
import com.liuzy.crawler.Main;

/**
 * @author liuzy
 * @since 2015年9月18日
 */
public class Logger {

	public static void cacheLog(int status, String fileName) {
		if (Config.cacheLog)
			switch (status) {
			case 0:
				log("Cache<" + fileName + ">success");
				break;
			case 1:
			case 2:
			case 3:
				log("Cache<" + fileName + ">cancel");
				break;
			case 4:
				log("Cache<" + fileName + ">failed");
				break;
			default:
				break;
			}
	}

	public static void scanLog(int status, String fileName) {
		if (Config.scanLog)
			switch (status) {
			case 0:
				log("Scan<" + fileName + ">success");
				break;
			case 1:
				log("Scan<" + fileName + ">cancel");
				break;
			case 2:
				log("Scan<" + fileName + ">failed");
				break;
			default:
				break;
			}
	}

	public static void dlLog(int status, String fileName) {
		if (Config.dlLog)
			switch (status) {
			case 0:
				log("Download<" + fileName + ">success");
				break;
			case 1:
			case 2:
			case 3:
				log("Download<" + fileName + ">cancel");
				break;
			case 4:
				log("Download<" + fileName + ">failed");
				break;
			default:
				break;
			}
	}

	public static void log(String msg) {
		Main.showMsg(msg + "\n");
		if (Config.consoleLog)
			System.out.println(msg);
	}

}
